from rest_framework import  serializers

from .models import Areas


class AreasSerializer(serializers.ModelSerializer):
    """list行为的序列化器"""
    class Meta:
        model = Areas
        fields = ('id', 'name')

class SubsAreasSerializer(serializers.ModelSerializer):
    """retrieve行为的序列化器"""
    subs = AreasSerializer(many=True, read_only=True)

    class Meta:
        model = Areas
        fields = ('id', 'name', 'subs')